//
//  ForumNextViewController.m
//  B段项目
//
//  Created by NeyMAr on 15/9/28.
//  Copyright (c) 2015年 昶博. All rights reserved.
//

#import "ForumNextViewController.h"
#import "UMSocial.h"
@interface ForumNextViewController () <UMSocialUIDelegate, UIWebViewDelegate>

@end

@implementation ForumNextViewController

- (void)viewWillAppear:(BOOL)animated
{
    SelfTabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.temp = 0;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"分享" style:UIBarButtonItemStylePlain target:self action:@selector(button:)];
    
    
    [self webViewSubview];
}


- (void)webViewSubview
{
    self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 375 * w, 667 * h)];
    [self.view addSubview:self.webView];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:self.strUrl]];
    [self.webView loadRequest:request];
    self.webView.delegate = self;
}


- (void)webViewDidStartLoad:(UIWebView *)webView
{
    self.activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 32 * w, h * 32)];
    self.activityIndicator.backgroundColor = [UIColor blackColor];
    _activityIndicator.center = CGPointMake(w * 375 / 2.0, h * 667/ 2.0 - h * 50);
    [_activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
    [self.view addSubview:_activityIndicator];
    
    [_activityIndicator startAnimating];
}


- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [_activityIndicator stopAnimating];
}


- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    [_activityIndicator stopAnimating];
}


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    if (self.temp++ == 0) {
        return YES;
    }
    return NO;
}


#pragma mark --分享按键方法
- (void)button:(UIButton *)button
{
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:@"507fcab25270157b37000010"
                                      shareText:self.strUrl
                                     shareImage:[UIImage imageNamed:@"icon.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToTencent,UMShareToRenren,nil]
                                       delegate:self];
}









#pragma mark - Memory
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
